//
//  SQ_Er_Cell.m
//  Hand-held_kitchen
//
//  Created by 张张烨 on 16/1/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SQ_Er_Cell.h"
#import "ZongTouwenjian.pch"
#import "ERERERCollectionViewCell.h"
#import "SheQumodel.h"
@interface SQ_Er_Cell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property(nonatomic,retain)UICollectionView *collectionView;


@end
@implementation SQ_Er_Cell
- (void)dealloc
{
    [_tupian release];
    [_zi release];
    [_arr3 release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        /**<  图片 */
        self.tupian = [[UIImageView alloc]init];
        _tupian.image = [UIImage imageNamed:@"我的1"];
        [self.contentView addSubview:_tupian];
        [_tupian release];
        /**<  字 */
        self.zi = [[UILabel alloc]init];
        _zi.font = [UIFont systemFontOfSize:14* KUAN];
        _zi.text = @"精品社区~~~~~~~~~~~~~~";
        _zi.textColor = [UIColor redColor];
        [self.contentView addSubview:_zi];
        [_zi release];
        
        [self coll];
        //        self.arr = [[NSArray alloc]init];
    }
    return self;
}
// 传值重点 重写set方法
-(void)setArr3:(NSArray *)arr3
{
    if (arr3 != nil) {
        [_arr3 release];
    }
    
    _arr3 = [arr3 retain];
    [_collectionView reloadData];
}


-(void)coll{
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    // cell大小
    layout.itemSize = CGSizeMake(90 * KUAN, 90 * GAO);
    // 行列间距
    layout.minimumLineSpacing = 5 * KUAN;
    layout.minimumInteritemSpacing = 1 *GAO;
    // 边界
    layout.sectionInset = UIEdgeInsetsMake(0, 10 * KUAN, 0, 10 * KUAN);
    // 滚动方向
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    
    // 创建过程类似tableView
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 30 * GAO, Width, 140 * GAO) collectionViewLayout:layout];
    _collectionView.backgroundColor = [UIColor whiteColor];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    [self.contentView addSubview:_collectionView];
    
    
    
    
    
    [_collectionView registerClass:[ERERERCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
    
}
/**<  coll item的个数 */
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
 
    
    return _arr3.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    ERERERCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    SheQumodel *m = _arr3[indexPath.item];

    /**<  只有一张图片 */
    [cell.touxiang sd_setImageWithURL:[NSURL URLWithString:m.image]];
    
    
    return cell;
    
}
/**<  点击方法 */
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    SheQumodel *m = _arr3[indexPath.row];
    
    [ self.deledate2 tiaotiao2:m.id1];
    
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}











-(void)layoutSubviews
{
    self.zi.frame = CGRectMake(60 * KUAN, 5 * GAO, 240 * KUAN, 30 * GAO);
    self.tupian.frame = CGRectMake(25 * KUAN, 10 * GAO, 20 * KUAN, 20 * GAO);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
